//
//  CTMediator+Message.m
//  KBMediator_Catrgories
//
//  Created by 肖雄 on 17/4/26.
//  Copyright © 2017年 kuaibao. All rights reserved.
//

#import "CTMediator+Message.h"

static NSString *Message = @"Message";
static NSString *messageMainController = @"messageMainController";
static NSString *KBMsgModelController = @"messageTemplateController";
static NSString *KBMarKetingMsgController = @"messageMarKetingController";
static NSString *KBMessageHistoryController = @"messageHistoryController";
static NSString *KBRecognizeImageTextController = @"messageScanMobilePhoneController";
static NSString *messageVoiceMobilePhoneController = @"messageVoiceMobilePhoneController";
static NSString *messageEnteringMobilePhoneController = @"messageEnteringMobilePhoneController";
static NSString *messageErrorReissueForMessageOrCloud = @"messageErrorReissueForMessageOrCloud";
static NSString *messagePickupPasswordForNewVersionSendMsg = @"messagePickupPasswordForNewVersionSendMsg";


@implementation CTMediator (Message)

- (UIViewController *)Message_mainController {
    return [self performTarget:Message action:messageMainController params:nil shouldCacheTarget:NO];
}

- (UIViewController *)Message_voiceMobilePhoneController:(void(^)(NSArray <NSString *>*phoneDatas))completionHandle {
    
    NSDictionary *params = nil;
    if (completionHandle) {
        params = @{@"completionHandle": [completionHandle copy]};
    }
    return [self performTarget:Message action:messageVoiceMobilePhoneController params:params shouldCacheTarget:NO];
}


- (UIViewController *)Message_enteringMobilePhoneController:(NSDictionary *)customParams completionHandle:(void (^)(NSArray<NSString *> *))completionHandle {
    
    NSDictionary *params = nil;
    if (completionHandle) {
        NSMutableArray *oldArr = [customParams objectForKey:@"oldArr"];
        params = @{@"completionHandle": [completionHandle copy],
                   @"oldArr": oldArr};
    }
    return [self performTarget:Message action:messageEnteringMobilePhoneController params:params shouldCacheTarget:NO];
}


- (UIViewController *)Message_scanMobilePhoneController:(void (^)(NSArray <NSString*>*))completionHandle {
    
    NSDictionary *params = nil;
    if (completionHandle) {
        params = @{@"completionHandle": [completionHandle copy]};
    }
    return [self performTarget:Message action:KBRecognizeImageTextController params:params shouldCacheTarget:NO];
}


- (UIViewController *)Message_templetControllerForNewVersionSendMsgWithCompletionHandle:(void(^)(NSDictionary *info))completionHandle {
    NSDictionary *params = nil;
    if (completionHandle) {
        params = @{@"callBack": [completionHandle copy]};
    }
    return [self performTarget:@"Message" action:@"templetControllerForNewVersionSendMsg" params:params shouldCacheTarget:YES];
}


- (UIViewController *)Message_PickupPasswordControllerWithCompletionHandle:(void (^)(NSDictionary *))completionHandle {
    NSDictionary *params = nil;
    if (completionHandle) {
        params = @{@"completionHandle": [completionHandle copy]};
    }
    return [self performTarget:Message action:messagePickupPasswordForNewVersionSendMsg params:params shouldCacheTarget:NO];
}


- (UIViewController *)Message_ErrorReissueController:(NSDictionary *)infoDict WithCompletionHandle:(void (^)(NSDictionary *))completionHandle {
    NSDictionary *params = nil;
    if (completionHandle) {
        if (infoDict.allValues.count > 0) {
            params = @{@"completionHandle": [completionHandle copy],
                       @"sendCode": infoDict[@"sendCode"],
                       @"failAutoCallIvid": infoDict[@"failAutoCallIvid"]};
        }
        else {
            params = @{@"completionHandle": [completionHandle copy],
                       @"sendCode": @"2",
                       @"failAutoCallIvid": @0};
        }
    }
    return [self performTarget:Message action:messageErrorReissueForMessageOrCloud params:params shouldCacheTarget:NO];
}


- (UIViewController *)Message_historyControllerForMessageMain:(NSString *)isFromMain {
    NSDictionary *params = nil;
    params = @{@"fromKey" : isFromMain};
    return [self performTarget:Message action:KBMessageHistoryController params:params shouldCacheTarget:NO];
}


- (UIViewController *)Message_historyController {
    return [self performTarget:Message action:KBMessageHistoryController params:nil shouldCacheTarget:NO];
}
- (UIViewController *)Message_templateController {
    return [self performTarget:Message action:KBMsgModelController params:nil shouldCacheTarget:NO];
}
- (UIViewController *)Message_marketingController {
    return [self performTarget:Message action:KBMarKetingMsgController params:nil shouldCacheTarget:NO];
}



- (UIViewController *)Message_messageControllerForBarGunWithWaybillNos:(NSArray<NSString *> *)waybillNos
{
    NSDictionary *params = @{@"waybillNos": waybillNos ?: @[]};
    
    return [self performTarget:@"Message" action:@"messageControllerForBargun" params:params shouldCacheTarget:YES];
}

- (UIViewController *)Message_messageControllerForSignAndErrorWithWaybillNos:(NSArray<NSString *> *)waybillNos
{
    NSDictionary *params = @{@"waybillNos": waybillNos ?: @[]};
    
    return [self performTarget:@"Message" action:@"messageControllerForSignAndError" params:params shouldCacheTarget:YES];
}

- (UIViewController *)Message_templetControllerForOtherWithCompletionHandle:(void (^)(NSDictionary *))completionHandle
{
    NSDictionary *params = nil;
    if (completionHandle) {
        
        params = @{@"callBack": [completionHandle copy]};
    }

    return [self performTarget:@"Message" action:@"templetControllerForOther" params:params shouldCacheTarget:YES];
}

- (UIViewController *)Message_messageControllerForDeliveryWithWaybillNos:(NSArray<NSString *> *)waybillNos
{
    NSDictionary *params = @{@"waybillNos": waybillNos ?: @[]};
    
    return [self performTarget:@"Message" action:@"messageControllerForDelivery" params:params shouldCacheTarget:YES];
}


- (void)Message_saveMessageToDraf:(NSDictionary *)drafParams
{
    [self performTarget:@"Message" action:@"saveMessageToDraf" params:drafParams shouldCacheTarget:YES];
}
@end
